﻿<html>

	<head>
		<title>购物车推荐</title>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">

		<link href="../../css/skin/default/style.css" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" href="../../css/dialog.css">
		<link href="../../js/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />

		<script src="../../js/lib/jquery/jquery-1.10.2.min.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>

		<script src="../../js/lib/ligerUI/js/plugins/ligerPopupEdit.js"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerLayout.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerForm.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerDateEditor.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerRadio.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerTextBox.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerSpinner.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerTree.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerDrag.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerResizable.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerTip.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerMenu.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerToolBar.js" type="text/javascript"></script>
		<script src="../../js/lib/jquery.form.js" type="text/javascript"></script>
		<script src="../../js/lib/json2.js" type="text/javascript"></script>
		<script src="../../js/dialog.js"></script>
		<script src="../../js/JS/layout.js"></script>
		<script src="../../js/constants.js" type="text/javascript"></script>
		<script src="../../js/api.js" type="text/javascript"></script>

		<script type="text/javascript">
			var manager;
			$(document).hover(parent.hindMenu);
			var mid = $api.getparastr("mid");
			var shopcatadUrl = BaseUrl + "ShopCartAD?token=" + $api.getStorage("token");
			$(function() {
				toolbar();
				var url = shopcatadUrl+"&sid=0&type=0&key=";
				manager = $("#maingrid4").ligerGrid({
					columns: [{
							display: '标题',
							name: 'title',
							align: 'left',
							width: 380,
							render: function(rowdata, rowindex, value) {
								var ret = "<img src=" + rowdata.Fhimg + " class='listimgs' style='float:left;top:5px' />";
								ret += "<div style=' margin-left:5px'><span  >" + rowdata.Fsummary + "</span><br/>";
								ret += "<span style='color:#999'>来源:" + rowdata.Fbrand + "</span>"
								ret += "<div>"
								return ret;

							}
						},
						{
							display: '分类',
							name: 'Fadtype',
							width: 120,
							isSort: true,
							render: function(rowdata, rowindex, value) {
								if(rowdata.Fadtype == 1) return '促销商品';
								else if(rowdata.Fadtype == 2) return '推荐商品';
								return "";
							}
						},
						{
							display: '货号',
							name: 'Fpcode',
							align: 'left',
							width: 120,
							isSort: true
						},
						{
							display: '条码',
							name: 'Fbarcode',
							align: 'left',
							width: 120
						},
						{
							display: '箱装数',
							name: 'Ft1',
							align: 'left',
							width: 120
						},
						{
							display: '大包装数',
							name: 'Ft2',
							align: 'left',
							width: 120
						},
						{
							display: '售价',
							name: 'Fsaleprice',
							type: 'currency',
							width: 100,
							align: 'right'
						},
						{
							display: '体积',
							name: 'Fc6',
							align: 'left',
							width: 120,
							render: function(rowdata, rowindex, value) {
								if(rowdata.Fc6) {
									return(rowdata.Fc6 * rowdata.Fnum).toFixed(6) + "立方米";
								}
								return "";
							}
						},
						{
							display: '毛重',
							name: 'Fc2',
							align: 'left',
							width: 120,
							render: function(rowdata, rowindex, value) {
								if(rowdata.Fc2) {
									return(rowdata.Fc2 * rowdata.Fnum).toFixed(3) + "KG";
								}
								return "";
							}
						},
						{
							display: '净重',
							name: 'Fc7',
							align: 'left',
							width: 120,
							render: function(rowdata, rowindex, value) {
								if(rowdata.Fc7) {
									return(rowdata.Fc7 * rowdata.Fnum).toFixed(3) + "KG";
								}
								return "";
							}
						},
						{
							display: '排序号',
							name: 'Frow',
							isSort: true,
							width: 140
						},
						{
							display: '操作时间',
							name: 'Frefreshdt',
							isSort: true,
							minwidth: 140,
							align: 'left'
						}
					],
					dataAction: 'local',
					url: url,
					method: 'get',
					width: '100%',
					height: '90%',
					rowHeight: 100,
					pageSize: 20,
					usePager: true, //是否分页  
					onDblClickRow: function(data, rowindex, rowobj) {
						addDialog = parent.openCommWindow('vsys/tb_shop_cart_ad/Add.html?data=' + escape(JSON.stringify(data)), "热门搜索词", 480, 270, 'hotkey');

					}
				});
			});
			//新增与保存
			function saveInfo(row, cmd) {
				if(cmd == 'shopcatad') {
					var url = shopcatadUrl + "&action=" + row.action;

					$api.ajax2(url, row.data, function(data) {
						f_reload();
					});
				}

			}

			function toolbar() {

				$api.getLimit(mid, 0,
					function(data) {
						$("#icon-list").append(data);
					});
			}

			function f_reload() {
				var manager = $("#maingrid4").ligerGetGridManager();
				manager.loadData(true);
			};

			function add() {
				addDialog = parent.openCommWindow('vsys/tb_shop_cart_ad/Add.html', "商品推荐设置", 480, 270, 'shopcatad');
			}
			var addDialog;

			function edit() {
				var row = manager.getSelectedRow();
				if(row) {
					addDialog = parent.openCommWindow('vsys/tb_shop_cart_ad/Add.html?data=' + escape(JSON.stringify(row)), "商品推荐设置", 480, 270, 'shopcatad');
				} else {
					$.ligerDialog.warn("请选择行");
				}
			}

			function putProducts(row) {
				if(addDialog)
					addDialog.frame.putProducts(row);
			}

			function del() {
				var row = manager.getSelectedRow();

				if(row) {

					$.ligerDialog.confirm("删除后不能恢复，\n您确定要移除？", function(yes) {
						if(yes) {
							var url = shopcatadUrl + "&action=del";

							$api.ajax2(url, row, function(data) {
								f_reload();
							});
						}
					})
				} else {
					$.ligerDialog.warn("请选择行！");
				}
			}

			var popPSid;
			var Fbid;

			function initContorl() {

				var url = BaseUrl + "SysStore?token=" + $api.getStorage("token") + "&key=";
				$api.ajaxget(url, {}, function(result) {

					popPSid = $("#PSid").ligerComboBox({
						data: result.Rows,
						valueField: 'Fid',
						textField: 'Fname',
						onChangeValue: function(obj) {
							Fbid = obj;
							doSearch(true);
						}
					});

				});
			}

			function doSearch(high) {
				var key = $("#key").val();
				var sender = "&key=" + key;  
					sender += "&type=" + $("#Ftype").val();		 
					
				if(popPSid.getValue())
					sender += "&sid=" + popPSid.getValue();
				else
					sender += "&sid=0";

				var url = ShopCartAD + sender;

				manager.GetDataByURL(url);

			}
		</script>

	</head>

	<body class="mainbody">
		<form id="form1" onsubmit="return false">
			<div>
				<div class="toolbar-wrap">
					<div class="toolbar">
						<div class="l-list">
							<ul id="icon-list" class="icon-list">
							</ul>
						</div>
					</div>
				</div>
				<div class="div-content">
					<dl>
						<dt style="width: 60px;">供应商</dt>
						<dd style="margin-left: 70px;">
							<div style="margin-left: 10px;float:left;">
								<input id="PSid" name="PSid" ligerui="{width:180}" />
							</div>
						</dd>
						<dt style="width: 60px;">推荐类别</dt>
						<dd style="margin-left: 70px;">
							<div style="margin-left: 10px;float:left;">
								<select name="Ftype" id="Ftype" ltype="select" ligerui="{width:180}">
									<option value="0" selected="selected">全部</option>
									<option value="1">促销商品</option>
									<option value="2">推荐商品</option>
								</select>
							</div>
						</dd>

						<dt style="width: 60px;">关键词</dt>
						<dd style="margin-left: 70px;">
							<div style="margin-left: 10px;float:left;">
								<input type="text" placeholder='品名/货号/条码' ID="key" name="key" ltype="text" ligerui="{width:180,initSelect:true;nullText:'品名/货号/条码'}" />
							</div>
							<div style="float:left;margin-left: 10px;">
								<input style="display:inline" type="button" value="搜索" class="btn" onclick="doSearch();" />
							</div>
						</dd>
					</dl>
				</div>
			</div>

			<div id="maingrid4" style="margin:-1px;background:#fff;"></div>
			<div class="div-content" style="margin-top: 10px;width:99.5%">
				<div class="divhead">信息管理小贴士</div>
				<hr class="divline" />

				<div style="padding:1px 5px; line-height:22px;"><span style="color:#FD0036">商品推荐在App商品分类中显示</span>
				</div>
			</div>
		</form>
	</body>

</html>